package com.bwie.parkdemo.mvvm.model.entity;

import android.text.TextUtils;

import com.bwie.lib_core.base.BaseEntity;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

/**
 * 已分组用
 * {\"departmentId\":47,\"departmentName\":\"技术部\",
 * \"departmentUserId\":47,\"pId\":1,\"time\":\"1583245030\",
 * \"token\":\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIxIiwiZXhwIjozMTY2NDkwMDYyLCJpYXQiOjE1ODMyNDUwMzF9.mhrf6__HRkGHo5lpKXsk_ryUwqWQGfAry6gS9u4d7RA\",
 * \"uId\":1,\"uName\":\"zxy\",\"uPwd\":\"123456\"}
 * */
public class DepartmentUserEntity extends BaseEntity{
    private String values;
    private List<Object> departmentUserValues;

    public List<Object> getDepartmentUserValues() {
        departmentUserValues = new ArrayList<>();
        if (TextUtils.isEmpty(values))
            return departmentUserValues;
        try {
            JSONArray jay = new JSONArray(values);
            for (int i = 0;i < jay.length();i ++){
                String jobStr = jay.getJSONObject(i).toString();
                Values values = new Gson().fromJson(jobStr,Values.class);
                departmentUserValues.add(values);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return departmentUserValues;
    }

    public void setValues(String values) {
        this.values = values;
    }

    public static class Values{
        public int departmentId;
        public String departmentName = "未添加部门";
        public int departmentUserId;
        public int pId;
        public String time;
        public int uId;
        public String uName;
        public String uPwd;
    }

}
